New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding <thead> to tables #387
Conversation
…mplements FS#1764
That makes no sense for a table like this:
A thead would only make sense when all cells in the first row are headers. |
3 questions:
|
about 1. : Of course i can add a counter in the existing for loop, but that i need to add a element before the current |
|
Thead should not only apply to the first row, but all contiguous rows at the top of the table where every cell is a <th> |
Wouldn't it be possible to store flags in the handler instance when the th elements are collected (i.e. before the processing step) that track in which row the first non-th table element occurred? |
There are two processing steps in the table call rewriter, process() & then tablefinalize() when process() hits tableend. Can you add a inHead flag and countHeadRows to the class. In process(), start with inHead true and set it to false when you hit the first tablecell. In rowclose increment countHeadRows if inHead is still true. Then when you get to finalizetable(), if countHeadRows is not zero put in your tableheadopen along with the tableopen and then put in the tableheadclose when you get to the nth (n = countHeadRows) tablerowclose. [ I'm not sure how to detect an unclosed rowspan, so i think perhaps you also set inHead flag to false if you hit any rowspan ] |
Klap-in, I've put my changes into the branch tablethead_chris and created a #390 for them to this branch. Please merge the PR if you are ok with the changes. |
multi-row THEAD & tests
I would disagree with that. A thead could have mostly th's, but it would be absolutely fine to have a few td's. One example I could think of is when the first cell is empty. I would always add a tbody. In normal tables it should be around everything. In tables where you add a thead, it should be around the rest. |
@selfthinker - re, tds in thead, can you give me an example of what you mean in dokuwiki syntax. |
E.g. the second table on here: https://www.dokuwiki.org/wiki:syntax#tables |
We'll need some definitive rules to test...how about?
|
@Chris--S These rules sound good to me. One addition: the row should have more than one cell. |
I disagree with "the row should have more than one cell". I can think of perfectly valid examples with just one column, where the first one is the th and the rest are tds. |
right, I guess the rule should be "should have more than one row" then |
Yes, that makes sense. |
What happened to this one? Only refining when to add |
@splitbrain @selfthinker can you clarify the comments from "One addition ..." to "... Yes, that makes sense". I don't see what effect the number of rows has. There can be one cell in a header row, but only if its a TH. That is allowed by my original two rules - they had an unstated assumption, when the rest of the cells are TH. |
In addition to above. How to treat these tables:
For me, first one does not get THEAD. And the second one does - by putting the '^' at the end of the row. |
If there is only one row, there shouldn't be a
The second is invalid syntax, so there won't be a good solution. Therefore it doesn't really matter what you do. ;-) |
Ok. so rule 3. table must have more than one row. The second syntax works perfectly well - https://www.dokuwiki.org/sandbox_table |
Yeah it's valid syntax. Up til now the last closing row char did not really matter and was usually the same as the opening char of the same cell, but there's no rule for that. I would like to avoid giving it meaning now. The leading char defines the cell type and we should only use that for deciding on theads IMHO. |
If you have 3, 3a is redundant. Or the other way around. Just to make this clear:
AFAIK it is not. wiki:syntax says:
That it works and doesn't break in the example above has nothing to do with validity. |
Its the other way around, 3a makes 3 rendundant. Consider: ^ r1c1 ^ r2c2 ^ Which I guess should result in a table containing all <TH> cells but no <THEAD> rows. |
Hmm, yeah, okay. |
…element 1. TD < 2 in a row 2. TD <= 50% of total cells 3. Not all table rows can be THEAD rows
Here are some sample tables, https://gist.github.com/Chris--S/9589178 This branch currently renders THEAD as described in the text. |
The samples look good to me, but the branch breaks a bunch of tests right now. |
👍 |
Is it useful to mention the thead feature of the tables at the wiki:syntax page? Or is it too technically, so too much buzz for a common wiki user? |
yeah, too much buzz for the end user I'd say |
I agree, syntax-wise it's not important and it's difficult to explain to non-technical people. It wouldn't even change the visible output (unless we, or a different template, added different styling for theads). |
Wrap thead around 1st row, when 1st cell at 1st row is tableheader.
Implements the feature request FS#1764